#pragma once

namespace config {


/**
 * A base class for all Config classes, manages "saved" state,
 * which is changed to <i>fase</i> once one of the values is changed.
 */
class ConfigBase {
public:
	inline ConfigBase(void) : m_isSaved(true) {}

	/**
	 * Checks whether one of the values was changed, and
	 * if yes - writes all the values to the registry
	 */
	inline void save(void) const {
		if (!m_isSaved)
			do_save();
		m_isSaved = true;
	}

	virtual ~ConfigBase(void) {}

protected:
	/** updates <i>saved</i> flag */
	inline void changed(void) { m_isSaved = false; }

	/** is implemented by child classes, and, actually, saves configuration to registry */
	virtual void do_save(void) const = 0;

private:
	mutable bool m_isSaved;
};


}  // end namespace
